home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
scope
/
001-025
/
scopedisk16
/
cw11
/
cw.doc
< prev
next >
Wrap
Text File
|
1995-03-18
|
4KB
|
117 lines
cw - one-shot stream editor
Version 1.1
Copyright (C) 1988 Daniel Elbaum
This code is freely redistributable on the condition that
nobody make money from it.
Syntax: cw <target> <replacement> <file> <file> <file> ...
<target> is the string you want to replace. This argument
may contain the following wildcards:
* - replaces any combination of characters.
Note that this departs from the more common
meaning of "zero or more occurences of the
preceding character".
If this metacharacter is not bounded by a
normal character, it may wreak havoc:
cw pat* chewie fubar
will replace everything from the first
occurrence of "pat" to the end of the file
with the string "chewie". But
cw pat*rn chewie fubar
will replace any sequence of characters which
starts with "pat" and ends with "rn". This
includes "pattern" as well as "repatched the
^ ^ ^
hull from stem to stern with fiberglass and mud."
^
. - replaces any single instance of any character:
d.g matches "dog", "dig", and so on.
? - same as '.' but won't match a space.
^ - matches the beginning of a line (but not a character).
cw ^frog pelvis autobiography
will change the word "frog" into the word "pelvis"
only where "frog" is the very first thing on a line.
$ - matches the end of a line (but not a character).
cw beer$ vaseline autobiography
will change the word "beer" into the word "vaseline"
only where "beer" is the very last thing on a line.
\t - matches a tab character: ^\t signifies a leading tab.
\n - matches a newline, so that
cw head\nfirst headfirst novella
will join any lines which are split between the 'd'
and the 'f' in "headfirst".
\r - matches a carriage return. These don't generally
appear in Amiga text files, but you may need it
someday.
\b - matches a backspace character.
\f - matches a formfeed.
The <replacement> argument may not contain wildcards except for
these two: ^$ and \0. They mean the same thing: replace the
target string with nothing (in other words, delete it).
The filename arguments may not contain wildcards.
Note that the changes are done IN PLACE. The wildcards are
dangerous when not closely supervised, so work on a copy of
the file, rather than the original.
New in Version 1.1:
-Fixed an output buffering problem wherein
the i/o buffer got flushed twice (it's a
long way to CON: ;{))
-Fixed a case wherein a few bytes of memory
were left unfreed when the target file
couldn't be found.
-Added a special-case replacement string arg,
"\0", to specify a null replacement string.
This feature avoids difficulties with the
quoting/argument-parsing conventions of
various command interpreters.
Please report any bugs or suggestions for enhancements to:
Daniel Elbaum
ARPA: elbaum@reed.EDU
UUCP: {oresoft,tektronix}!reed!elbaum
BBS:
Portland, OR:
NAG
Amigaboard! (user #217)
California:
AMIC